package com.yy.wga.mp.module.user.controller;

import com.yy.wga.common.core.dto.Result;
import com.yy.wga.mp.common.aop.NotLogin;
import com.yy.wga.mp.module.user.manager.UserManager;
import com.yy.wga.mp.module.user.request.WxAuthCode2SessionRequest;
import com.yy.wga.mp.module.user.response.WxAuthCode2SessionResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信公众号管理
 *
 * @author <a href="mailto:ludezh@dingtalk.com"> ludezh </a>
 * @version 1.0.0   2020/6/5,11:30
 * @since 1.0.0     2020/6/5,11:30
 */
@RestController
@RequestMapping(value = "/api/user/officialAccount/")
public class UserOfficialAccountController {
    @Autowired
    private UserManager userManager;

    /**
     * 小程序微信code登录，没有用户信息
     *
     * @param request
     * @return
     */
    @NotLogin
    @PostMapping("authCode2Session")
    public Result<WxAuthCode2SessionResponse> authCode2Session(@Validated @RequestBody WxAuthCode2SessionRequest request) {
        return Result.success(userManager.officialAccountAuthCode2Session(request));
    }
}
